var app = new Vue({
	el: '#app',
	data: {
		host:globalData.constParam.url.baseUrl+'/',
		url:{
			uploadHeadImg:'/api/UserInfo/UploadHeadImg' //上传头像
		},
		type:3,	//左侧类型
		collection_type:0,	//收藏Tab
		letter_type:0,	//站内信类型
		infos:{
			user:globalData.userInfo,
			signed_step:0, //选择签约用户，上传图片
		},//用户的所有信息		
		new_username:'', //新用户名
		new_eamil:'', //新邮箱
		tel:'123',
		time:'',
		code_tips:'获取验证码',
		err:false,		
		
		children_data:{
			isShow:false,
			CustomerID:''
		},
		icon:'',//头像地址
	},
	created:function(){
		if(!globalData.userIsLogin()){
			location.href = 'index.html'
		}
	},
	mounted: function() {		
		var that = this
		globalData.getTempToken(function(){
			if(globalData.utils.getUrl()&&globalData.utils.getUrl().type){
				that.type = globalData.utils.getUrl().type
			}
			//隐藏loading
			$('.loading').hide()
		})		
	},
	methods: {
		slideDown_up:function(ev,targetClass){
			var dom = $(ev.target)
			var targetDom = globalData.utils.get_target_dom(dom,targetClass)			
			if(targetDom.hasClass('active')){
				targetDom.removeClass('active')
			}else{
				targetDom.addClass('active')
			}
		},
		addImg: function(e) {
			var that = this;
			var file = e.target.files[0]
			var oFReader = new FileReader();
			oFReader.readAsDataURL(file);
			oFReader.onload = function(oFREvent) {
				var s = oFREvent.target.result;
				var index = s.indexOf(',')
				var t = s.substring(index+1,s.length)
//				console.log(t)			
				$(e.target).siblings('img').prop("src", s);
				that.icon = t;				
			};
		},
		upload_icon:function(){
			var that = this
			if(!that.icon){
				return;
			}
			var data = {
				HeadImg:that.icon
			}
			globalData.ajaxPost(that.url.uploadHeadImg,data,function(res){
				console.log(res)
				if(res.suc){					
					that.icon = ''
					that.infos.user.HeadImg = res.data
					globalData.setStorage(globalData.constParam.param.UTOKEN, that.infos.user);
					$('#alert').modal()
					$("#alert p").text('上传成功')
				}
			})
		}
	}
})